package jlib.component.list
{
	import flash.events.Event;
	import flash.text.TextFieldAutoSize;
	
	import jlib.component.button.LabelButton;

	public class LabelItem extends AbstractItem {
		
		private var m_label:String;
		private var m_button:LabelButton;
		private var m_data:Object;
		
		public function LabelItem($label:String=null, $labelWidth:Number=20, $labelHeight:Number=16, $align:String='center', $autoSize:String=TextFieldAutoSize.NONE) {
			m_button = new LabelButton;
			m_button.setToggle(true);
			setLabel($label);
			setLabelAutoSize($autoSize);
			setLabelSize($labelWidth, $labelHeight);
			setLabelAlign($align);
			addChild(m_button);
		}
		
		public function setLabelAlign($align:String): void  {
			m_button.setLabelAlign($align);
		}
		
		public function setLabelSize($width:Number, $height:Number): void  {
			m_button.setLabelSize($width, $height);
		}
		
		public function setLabelAutoSize($autoSize:String): void {
			m_button.setLabelAutoSize($autoSize);
		}
		
		public function getLabel(): String { return m_button.getLabel(); }
		public function setLabel($label:String): void {
			if(!$label) $label = '', trace('ListItem.setLabel 메서드 $label 인자 Null => \"\"');
			m_button.setLabel($label);
		}
		
		override public function isSelected():Boolean  { return m_button.isSelected(); }
		
		override public function select(e:Object=null): void { 
			if(!m_button.isSelected()) m_button.toggle(); 
		}
		
		override public function deselect(e:Object=null): void  { 
			if(m_button.isSelected()) m_button.toggle(); 
		}
		
		override public function setData($data:Object): void {
			m_data = $data;
		}
		
		override public function getData():Object {
			return m_data;
		}
	}
}